package ph.com.gs3.formalistics.model.tables;

public class CommentsTable extends AbstractDataTable {

	public static final String TAG = CommentsTable.class.getSimpleName();

	// table name
	public static final String NAME = "Comments";

	// table columns
	public static final String COL_ID = "_id";
	public static final String COL_WEB_ID = "web_id";
	public static final String COL_DOCUMENT_FORM_WEB_ID = "document_form_web_id";
	public static final String COL_DOCUMENT_WEB_ID = "document_web_id";
	public static final String COL_SERVER = "server";
	public static final String COL_COMMENT_TEXT = "comment_text";
	public static final String COL_DATE_CREATED = "date_created";
	public static final String COL_AUTHOR_WEB_ID = "author_web_id";
	public static final String COL_IS_OUTGOING = "is_outgoing";
	public static final String COL_MARKED_FOR_DELETION = "marked_for_deletion";

	// @formatter:off
	public static final String[] JOINED_TABLE_COLUMNS = { 
			NAME + "." + COL_ID, 					NAME + "." + COL_WEB_ID, 
			NAME + "." + COL_DOCUMENT_FORM_WEB_ID, 	NAME + "." + COL_DOCUMENT_WEB_ID, 	
			NAME + "." + COL_SERVER, 				NAME + "." + COL_COMMENT_TEXT,
			NAME + "." + COL_DATE_CREATED, 			NAME + "." + COL_AUTHOR_WEB_ID,
			NAME + "." + COL_IS_OUTGOING,			NAME + "." + COL_MARKED_FOR_DELETION,
			
			UserAccountTable.NAME + "." + UserAccountTable.COL_DISPLAY_NAME, 
			UserAccountTable.NAME + "." + UserAccountTable.COL_IMAGE_URL
	};
	// @formatter:on

	@Override
	public String[] getTableColumns() {
		return new String[] { COL_ID, COL_WEB_ID, COL_DOCUMENT_FORM_WEB_ID, COL_DOCUMENT_WEB_ID,
		        COL_SERVER, COL_COMMENT_TEXT, COL_DATE_CREATED, COL_AUTHOR_WEB_ID, COL_IS_OUTGOING,
		        COL_MARKED_FOR_DELETION };
	}

	@Override
	protected String getCreateTableQuery() {
		// @formatter:off
		return "CREATE TABLE " + NAME 		+ "(" 
				+ COL_ID 					+ " INTEGER PRIMARY KEY AUTOINCREMENT, "
		        + COL_WEB_ID 				+ " TEXT NOT NULL, "
		        + COL_DOCUMENT_FORM_WEB_ID 	+ " TEXT NOT NULL, "
		        + COL_DOCUMENT_WEB_ID 		+ " TEXT NOT NULL, " 
		        + COL_SERVER 				+ " TEXT NOT NULL, "		        
		        + COL_COMMENT_TEXT 			+ " TEXT NOT NULL, "
		        + COL_DATE_CREATED 			+ " TEXT NOT NULL, "
		        + COL_AUTHOR_WEB_ID 		+ " TEXT NOT NULL, "
		        + COL_IS_OUTGOING 			+ " INTEGER, "
		        + COL_MARKED_FOR_DELETION	+ " INTEGER"
		        + "); ";
		// @formatter:on
	}

	@Override
	protected String getTableName() {
		return NAME;
	}

}
